﻿
@Html.DevExpress().GridView(
settings =>
{
    settings.Name = "gridView";
    settings.InitDefaultPagerGridViewSettings();
    settings.EnableAlternatingRowColor();
    settings.CallbackRouteValues = new { Controller = "System", Action = "DeptPartialView" };

    settings.KeyFieldName = "deptcode";
    settings.AddDeptKindColumn().GroupIndex = 0;
    settings.SettingsBehavior.AutoExpandAllGroups = true;
    
    settings.Columns.Add("deptname", "单位名称");
    settings.Columns.Add("short_name","单位简称");
    settings.Columns.Add("cqep_dept_name", "对应门户单位");
    settings.AddYesNoColumn("use_flag", "是否启用");

    settings.Columns.Add(col =>
    {
        col.CellStyle.Paddings.Padding = 1;
        col.CellStyle.Paddings.PaddingLeft = 5;
        col.Caption = "";
        col.Width = 160;
        col.CellStyle.HorizontalAlign = HorizontalAlign.Center;

        col.SetDataItemTemplateContent(c =>
        {
            string key = DataBinder.Eval(c.DataItem, "deptcode").ToString();
            ViewContext.Writer.Write(
                Html.ActionLink("[编辑下级单位]", "DeptChildList", new { id = key })
                + "&nbsp;" +
                Html.ActionLink("[编辑]", "", null, new { href = "javascript:edit('" + key + "');" }) 
                //Html.ActionLink("[编辑]", "EditDept", new { id = key })
                +"&nbsp;"+
                Html.ActionLink("[删除]", "DeleteDept", new { id = key }, new { onclick = "return confirm('是否要删除选定的单位?')" })
                
            );
        }
        );
    });
    
    //settings.AddYesNoColumn2("loginenable", "是否启用");
    //settings.AddYesNoColumn("is_super", "是否管理员");
}).BindEF((s, e) => {
        e.KeyExpression = "deptcode";
        e.QueryableSource = this.GetDeptList();
        e.DefaultSorting = "deptcode asc";
    }).GetHtml()
